<template>
  <!-- 底部部分 => list有数据的时候，才展示  list.length > 0 -->
  <footer  class="footer">
    <span class="todo-count"><strong>{{rest}}</strong>剩余</span>
    <ul class="filters">
      <li>
        <a  href="#/" :class="{selected:this.status==='all'}" @click="$emit('dealdone','all')">全部</a>
      </li>
      <li>
        <a  href="#/active" :class="{selected:this.status==='undone'}"  @click="$emit('dealdone','undone')">进行中</a>
      </li>
      <li>
        <a  href="#/completed" :class="{selected:this.status==='done'}"  @click="$emit('dealdone','done')">已完成</a>
      </li>
    </ul>
    <!-- 有已完成的任务，才需要显示这个按钮 -->
    <button  class="clear-completed" @click="$emit('del')">清除已完成</button>
  </footer>
</template>

<script>
export default {
  props:{
    list:{
      type:Array,
      required:true,
    },
    status:{
      type:String,
      required:true,
      validator(val){
        return ['done','undone','all'].includes(val)
      }
    }
  },
  computed:{
    rest(){
      return this.list.filter(item=>item.done===false).length
    }
  }
}
</script>

<style></style>
